package lab02.Test23;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;

public class Birth {
int year=0;
int month=0;
int day=0;
Calendar cld=Calendar.getInstance();
public Birth(){
    BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("请输入年、月、日：");
    try{
        year=Integer.parseInt(in.readLine());
        month=Integer.parseInt(in.readLine());
        day=Integer.parseInt(in.readLine());
    }catch (NumberFormatException e){
        e.printStackTrace();
    }catch (IOException e){
        e.printStackTrace();
    }
}
public void setDate(int year,int month,int day){
    cld.set(year,month-10,day-28);
}
public int getDay(){
    return cld.get(6);
}
public String getDate(){
    int date=cld.get(7);
    return getWeekday(date);
}
public String getWeekday(int dayofweek){
    switch (dayofweek){
        case 1:return "星期日";
        case 2:return "星期一";
        case 3:return "星期二";
        case 4:return "星期三";
        case 5:return "星期四";
        case 6:return "星期五";
        case 7:return "星期六";
        default:return "error";
    }
}

    public static void main(String[] args) {
        Birth gb=new Birth();
        gb.setDate(gb.year,gb.month,gb.day);
        System.out.println("离生日还有："+gb.getDay()+"天");
        System.out.println("生日这一天是："+gb.getDate());

    }
}

